package unclassified.simple;

import java.util.PriorityQueue;

public class LargestNumberAtLeastTwiceOfOthers_747 {

    public int dominantIndex(int[] nums) {
        PriorityQueue<Integer> queue = new PriorityQueue<>((a, b) -> nums[b] - nums[a]);
        for (int i = 0; i < nums.length; i++) {
            queue.offer(i);
        }
        Integer poll = queue.poll();
        return queue.isEmpty() || nums[poll] >= nums[queue.peek()] * 2 ? poll : -1;
    }
}
